import React from "react";
import { AuthContext } from "../contexts/authContext";

const Header = () => {
    const { state, dispatch } = React.useContext(AuthContext)
    console.log(state);
    return (
        <>
            Header
            {state.isAuthenticated?(<div>登录了 {state.user.name}:{state.token}
                <button onClick={() => dispatch({
                    type: "LOGOUT"
                })}>退出</button>
            </div>):(<div>未登录</div>)}
        </>
    )
}

export default Header